package cn.ljx.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.ljx.entity.JsonReturn;
import cn.ljx.entity.TBEvaluate;
import cn.ljx.entity.TBUser;
import cn.ljx.service.TBEvaluateService;
import cn.ljx.util.BaseUtils;

@Controller
@RequestMapping("/evaluate")
public class EvaluateController {

	@Autowired
	private TBEvaluateService tbEvaluateService;
	
	@ResponseBody
	@RequestMapping(value="/addEvaluate",method=RequestMethod.POST)
	public JsonReturn addEvaluate(TBEvaluate tbEvaluate,Model model,HttpSession httpsession){
		JsonReturn jr = new JsonReturn();
		TBUser userSession = (TBUser) httpsession.getAttribute("tbuser");
		try {
			tbEvaluate.setId(BaseUtils.getUUID32());
			tbEvaluate.setCreate_time(BaseUtils.getTime());
			tbEvaluate.setCreate_name(userSession.getReal_name());
			tbEvaluate.setState("1");
			int i = tbEvaluateService.addEvaluate(tbEvaluate);
			if(i!=0){
				jr.setInfo("success");
			}else{
				jr.setInfo("false");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return jr;
	}
}
